/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "BRANCH_ENTERPRISE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "BranchEnterprise.findAll", query = "SELECT b FROM BranchEnterprise b"),
    @NamedQuery(name = "BranchEnterprise.findByIdBranchenterprise", query = "SELECT b FROM BranchEnterprise b WHERE b.branchEnterprisePK.idBranchenterprise = :idBranchenterprise"),
    @NamedQuery(name = "BranchEnterprise.findByIdEnterprise", query = "SELECT b FROM BranchEnterprise b WHERE b.branchEnterprisePK.idEnterprise = :idEnterprise"),
    @NamedQuery(name = "BranchEnterprise.findByMultilevel", query = "SELECT b FROM BranchEnterprise b WHERE b.multilevel = :multilevel")})
public class BranchEnterprise implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected BranchEnterprisePK branchEnterprisePK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MULTILEVEL")
    private Integer multilevel;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "branchEnterprise", fetch = FetchType.LAZY)
    private List<Rule> ruleList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "branchEnterprise", fetch = FetchType.LAZY)
    private List<Campaign> campaignList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "branchEnterprise", fetch = FetchType.LAZY)
    private List<Catalog> catalogList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "branchEnterprise", fetch = FetchType.LAZY)
    private List<Warehouse> warehouseList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "branchEnterprise", fetch = FetchType.LAZY)
    private List<Service> serviceList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "branchEnterprise", fetch = FetchType.LAZY)
    private List<Product> productList;
    @JoinColumn(name = "ID_LOCATION", referencedColumnName = "ID_LOCATION")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Location idLocation;
    @JoinColumn(name = "ID_ENTERPRISE", referencedColumnName = "ID_ENTERPRISE", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Enterprise enterprise;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "branchEnterprise", fetch = FetchType.LAZY)
    private List<PersonalInfo> personalInfoList;

    public BranchEnterprise() {
    }

    public BranchEnterprise(BranchEnterprisePK branchEnterprisePK) {
        this.branchEnterprisePK = branchEnterprisePK;
    }

    public BranchEnterprise(BranchEnterprisePK branchEnterprisePK, Integer multilevel, Location l) {
        this.branchEnterprisePK = branchEnterprisePK;
        this.multilevel = multilevel;
        this.idLocation=l;
    }

    public BranchEnterprise(BigInteger idBranchenterprise, BigInteger idEnterprise) {
        this.branchEnterprisePK = new BranchEnterprisePK(idBranchenterprise, idEnterprise);
    }

    public BranchEnterprisePK getBranchEnterprisePK() {
        return branchEnterprisePK;
    }

    public void setBranchEnterprisePK(BranchEnterprisePK branchEnterprisePK) {
        this.branchEnterprisePK = branchEnterprisePK;
    }

    public Integer getMultilevel() {
        return multilevel;
    }

    public void setMultilevel(Integer multilevel) {
        this.multilevel = multilevel;
    }

    @XmlTransient
    public List<Rule> getRuleList() {
        return ruleList;
    }

    public void setRuleList(List<Rule> ruleList) {
        this.ruleList = ruleList;
    }

    @XmlTransient
    public List<Campaign> getCampaignList() {
        return campaignList;
    }

    public void setCampaignList(List<Campaign> campaignList) {
        this.campaignList = campaignList;
    }

    @XmlTransient
    public List<Catalog> getCatalogList() {
        return catalogList;
    }

    public void setCatalogList(List<Catalog> catalogList) {
        this.catalogList = catalogList;
    }

    @XmlTransient
    public List<Warehouse> getWarehouseList() {
        return warehouseList;
    }

    public void setWarehouseList(List<Warehouse> warehouseList) {
        this.warehouseList = warehouseList;
    }

    @XmlTransient
    public List<Service> getServiceList() {
        return serviceList;
    }

    public void setServiceList(List<Service> serviceList) {
        this.serviceList = serviceList;
    }

    @XmlTransient
    public List<Product> getProductList() {
        return productList;
    }

    public void setProductList(List<Product> productList) {
        this.productList = productList;
    }

    public Location getIdLocation() {
        return idLocation;
    }

    public void setIdLocation(Location idLocation) {
        this.idLocation = idLocation;
    }

    public Enterprise getEnterprise() {
        return enterprise;
    }

    public void setEnterprise(Enterprise enterprise) {
        this.enterprise = enterprise;
    }

    @XmlTransient
    public List<PersonalInfo> getPersonalInfoList() {
        return personalInfoList;
    }

    public void setPersonalInfoList(List<PersonalInfo> personalInfoList) {
        this.personalInfoList = personalInfoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (branchEnterprisePK != null ? branchEnterprisePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BranchEnterprise)) {
            return false;
        }
        BranchEnterprise other = (BranchEnterprise) object;
        if ((this.branchEnterprisePK == null && other.branchEnterprisePK != null) || (this.branchEnterprisePK != null && !this.branchEnterprisePK.equals(other.branchEnterprisePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.BranchEnterprise[ branchEnterprisePK=" + branchEnterprisePK + " ]";
    }
    
}
